package com.test.byteDance;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Byte2019_1 {
    public ArrayList<Character> errorCorrection(char[] errorStr) {
        ArrayList<Character> correctStr = new ArrayList<>();
        int i = 0;
        while (i < errorStr.length) {
            i += detectStr(errorStr, correctStr, i);
        }

        return correctStr;
    }

    public int detectStr(char[] errorStr, List<Character> correctStr, int i) {
        correctStr.add(errorStr[i]);
        boolean flage = false;
        // 靠前的两个字母相同
        if ((correctStr.size() - 3 >= 0) && correctStr.get(correctStr.size() - 2).equals(correctStr.get(correctStr.size() - 3))) {
            flage = true;
        }
        int jump = 1;
        if (!flage) {
            // 如果靠前两个字母不相同
            if (((i + 1) < errorStr.length) && (errorStr[i] == errorStr[i + 1])) {
                jump++;
                correctStr.add(errorStr[i + 1]);
            }
        }
        // 如果靠前两个字母相同
        while (((i + jump) < errorStr.length) && (errorStr[i] == errorStr[i + jump])) {
            jump++;
        }

        return jump;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        String[] errorStrs = new String[N];
        Byte2019_1 byte2019_1 = new Byte2019_1();
        for (int i = 0; i < N; i++) {
            errorStrs[i] = scanner.next();
        }
        for (String errorStr : errorStrs) {
            for (Character character : byte2019_1.errorCorrection(errorStr.toCharArray())) {
                System.out.print(character);
            }
            System.out.println();
        }
    }
}
